'use strict';
/**
 * @name: c2b下单模块
 * @description: c2b下单模块
 * @version: 1.0.0
 * @author: ljr
 * @Date: 2020-12-24
 * @LastEditors: ljr
 * @LastEditTime: 2020-12-24
 */

const ctxutil = require('./utildev/exploitInitCtx/initctx/index.js');

const Customtrade = require("./utildev/mf-customtrade/index").CustomTrade;
// 插入
exports.addOrderInfo = async (ctx) => {
  
  await ctxutil.apply(ctx);

  let _customtrade = new Customtrade(ctx);

  // 存储订单信息
  let res = await _customtrade.addOrderInfo({
    userId : ctx.userNick || ctx.mixNick,
    mixNick: ctx.mixNick,
    openId: ctx.openId,
    ...ctx.data
  });

  return res

}


// 查询
exports.getOrderInfo = async (ctx) => {
  
  await ctxutil.apply(ctx);

  let _customtrade = new Customtrade(ctx);

  // 存储订单信息
  let res = await _customtrade.getOrderInfo({
    ...ctx.data
  });

  return res

}


//保存订单表中用户的交易记录
exports.updateOrderInfo = async (ctx)=> {
  await ctxutil.apply(ctx);

  let _customtrade = new Customtrade(ctx);

   let res = await _customtrade.updateOrderInfo({
    ...ctx.data
   });

   return res
}


exports.updateOrderInfoByTime = async (ctx)=> {
  await ctxutil.apply(ctx);

  let _customtrade = new Customtrade(ctx);

   let res = await _customtrade.updateOrderInfoByTime();

   return res
}